package com.lzy.cloud.order.strategy;

import com.lzy.cloud.order.dtos.BaseOrderDto;
import com.lzy.cloud.order.dtos.PayOrderMoneyDto;

/**
 * @Description: Context上下文，用一个具体的策略来配置，维护一个对Strategy对象的引用
 * @Author:   gyl
 * @Date:     2018/7/6 16:35
 */
public class StrategyOrderContext {

    private StrategyOrder strategyOrder;

    public void setCommonsOrder(StrategyOrder strategyOrder) {
        this.strategyOrder = strategyOrder;
    }

    public BaseOrderDto createOrder(BaseOrderDto dto) {
        return strategyOrder.createOrder(dto);
    }

    public PayOrderMoneyDto confirmPay(BaseOrderDto dto) {
        return strategyOrder.confirmPay(dto);
    }

    public <V extends BaseOrderDto> V selectOrderByOrderId(String orderId) {
        return (V) strategyOrder.selectOrderByOrderId(orderId);
    }

    public void confirm(BaseOrderDto dto) {
        strategyOrder.confirm(dto);
    }

    public void cancel(BaseOrderDto dto) {
        strategyOrder.cancel(dto);
    }

}
